% comparison to Water1998 and Kushiro1996 experiments
WalterElements = {'SiO2'	'TiO2'	'Al2O3'	'Cr2O3'	'FeO'	'MgO'	'CaO'	'K2O'	'Na2O' 'P(kbars)'};
[A,ElementIndicies4Target] = ismember(PetrogenMajorElement_Strings_Extracted,WalterElements);
AcceptableRange = [96 102];



Liquids_3GPA_Walter1998 = [46.17	0.91	13.32	0.31	9.55	16.9	10.69	0.56	0.96	30	0.138
46.66	0.7	13.06	0.35	8.75	17.58	10.92	0.41	0.93	30	0.185
46.91	0.64	12.46	0.43	8.86	18.22	10.86	0.34	0.82	30	0.244
48.98	0.48	11.06	0.55	9.45	19.71	8.78	0.23	0.77	30	0.372
47.96	0.39	9.5	0.51	9.19	23.89	7.7	0.22	0.52	30	0.527];
F_Walter3GPA = Liquids_3GPA_Walter1998(:,end);
Liquids_3GPA_Walter1998 = sumMgNumNorm_PT(Liquids_3GPA_Walter1998,ElementIndicies4Target,AcceptableRange);
Liquids_3GPA_Walter1998(:,end)=F_Walter3GPA;



Liquids_4GPA_Walter1998 = [46.38	1.45	9.81	0.33	10.65	18.58	10.31	0.83	0.93	40	0.092
45.52	1.27	10.35	0.25	10.65	19.89	9.31	0.7	1.08	40	0.129
46.17	0.46	10.28	0.48	9.67	22.31	8.96	0.22	0.4	40	0.388];
F_Walter4GPA = Liquids_4GPA_Walter1998(:,end);
Liquids_4GPA_Walter1998 = sumMgNumNorm_PT(Liquids_4GPA_Walter1998,ElementIndicies4Target,AcceptableRange);
Liquids_4GPA_Walter1998(:,end)=F_Walter4GPA;



Liquids_4point5GPA_Walter1998 = [45.97	1.66	8.27	0.34	11.72	20.02	9.2	0.99	1.11	45	0.122
46.01	0.49	9.01	0.46	10.12	24.37	8.16	0.29	0.58	45	0.372];
F_Walter4point5GPA=Liquids_4point5GPA_Walter1998(:,end);
Liquids_4point5GPA_Walter1998 = sumMgNumNorm_PT(Liquids_4point5GPA_Walter1998,ElementIndicies4Target,AcceptableRange);
Liquids_4point5GPA_Walter1998(:,end)=F_Walter4point5GPA;



Liquids_5GPA_Walter1998 = [44.78	1.26	7.15	0.31	11.88	22.28	9.54	0.6	0.86	50	0.1];
F_Walter5GPA=Liquids_5GPA_Walter1998(:,end);
Liquids_5GPA_Walter1998 = sumMgNumNorm_PT(Liquids_5GPA_Walter1998,ElementIndicies4Target,AcceptableRange);
Liquids_5GPA_Walter1998(:,end)=F_Walter5GPA;




Liquids_6GPA_Walter1998 = [44.97	1.01	6.37	0.35	12.64	23.26	9.05	0.36	0.8	60	0.11
45.45	0.91	6.5	0.41	11.77	23.88	8.66	0.61	0.86	60	0.194
46.48	0.49	7.27	0.43	10.24	26.18	7.33	0.23	0.45	60	0.411
46.9	0.36	8.79	0.57	9.87	26.48	6.8	0.18	0.43	60	0.497
47.19	0.3	7.26	0.52	8.6	29.34	5.48	0.14	0.39	60	0.65];
F_Walter6GPa = Liquids_6GPA_Walter1998(:,end);
Liquids_6GPA_Walter1998 = sumMgNumNorm_PT(Liquids_6GPA_Walter1998,ElementIndicies4Target,AcceptableRange);
Liquids_6GPA_Walter1998(:,end)=F_Walter6GPa;


Liquids_7GPA_Walter1998 = [45.15	1.23	5.09	0.36	12.53	23.9	8.62	0.91	1.04	70	0.157
46.11	0.66	5.43	0.37	11.61	25.29	8.49	0.3	0.63	70	0.217
47.02	0.58	6.26	0.49	10.58	26.65	7.42	0.25	0.56	70	0.351
47.09	0.43	6.27	0.47	9.64	27.31	7.26	0.15	0.65	70	0.474
47.33	0.28	6.45	0.5	8.61	30.29	5.61	0.11	0.41	70	0.681
45.39	0.21	5.72	0.43	8.17	34.87	4.27	0.13	0.28	70	0.862];
F_Liquids_7GPA_Walter1998=Liquids_7GPA_Walter1998(:,end);
Liquids_7GPA_Walter1998 = sumMgNumNorm_PT(Liquids_7GPA_Walter1998,ElementIndicies4Target,AcceptableRange);
Liquids_7GPA_Walter1998(:,end)=F_Liquids_7GPA_Walter1998;


WalterOn = input('Compare to Walter et al. 1998? (KLB)? If yes, enter 1:');

%% Alleged F-major elements
    close all


IndiciesFig1_Y = {'SiO2','TiO2','Al2O3','Cr2O3','FeO','MgO','CaO','Na2O','K2O','Mg#'};
 



numrows=1;
numcolumns=1;

[a,xxxvalue]=ismember('Lnexp_cumulative',ConstraintOptions);
[a,SMvalue]=ismember('FN or FP',ConstraintOptions);


set(gcf, 'Units', 'Inches', 'Position', [5.5417 0.4583 8.4444 12.7917], 'PaperUnits', 'Inches', 'PaperSize', [8.5, 11])
hold on


for n = 1:size(IndiciesFig1_Y,2)
    
    
    figure(n)
    close
    figure(n)
    hold on
    accumulatingLegend={}; 
    subaxis(numrows,numcolumns,1,'Spacing',.08,'Margin',0.02,'MarginBottom',.06,'MarginLeft',.08,'Padding',0.05,'PaddingLeft',0.02)
    %axis(axesMinors(n,:))

FigureTitle = sprintf('F_%s',IndiciesFig1_Y{n});
set(gcf,'name',regexprep(FigureTitle,'\_*',''))
set(gcf,'name',FigureTitle)


    hold on

    box on
    
    
    yvalueName =  upper(IndiciesFig1_Y(n));
    [a,yvalue]=(ismember(yvalueName, upper(PetrogenMajorElement_Strings_Extracted)));
        
    
    
    for iik=1:numberModels
        
        layerplot_color_here = eval(char(layerplot_color(iik)));
        layerplot_color_here_fill = eval(char(layerplot_color_fill(iik)));
        layerplot_color_here_edge = eval(char(layerplot_color_edge(iik)));
        mymarkersize = layerplot_markersize(iik);
        layerplot_marker_here = char(layerplot_marker(iik));
        

         
                    
                    
        if any((strfind(TabNames{iik},'SM')))==1
            LegendModelcounter=1; 
            numdatapts = size(eval(sprintf('DataRatios_%s(:,%g)', TabNames{iik}, yyvalue)),1);
            layerplot_marker_here = SM_Markers;
            mymarkersizeSpecial = 3;
            for lll = whichPrimarySM2plot
                
                
                    if LegendModelcounter==1
                         LegOnOff = 'on';
                    else
                        LegOnOff = 'off';
                    end
                    
                 
                mymarkersize = SM_MarkerSize(lll) ;
                groupedindicies=lll:11:numdatapts;
                
                
                plot(100.*eval(sprintf('%s_InfoALL(groupedindicies,%d)', TabNames{iik},SMvalue)),...
                    eval(sprintf('%s(groupedindicies,%g)',TabNames{iik}, yvalue)),...
                    char(layerplot_marker_here(lll)),...
                    'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,'LineWidth',SM_LineWidth(lll),'MarkerSize',mymarkersize)
                
       
                    LegendModelcounter=LegendModelcounter+1;
                end  
                    accumulatingLegend={accumulatingLegend{:} names4legend_all_sources{iik}}; 
        else
            
        
 
            
            
            plot(100.*eval(sprintf('%s_InfoALL(:,%d)', TabNames{iik},xxxvalue)),...
                eval(sprintf('%s(:,%g)', TabNames{iik}, yvalue)),...
                layerplot_marker_here,...
                'Color',layerplot_color_here,'MarkerFaceColor',layerplot_color_here_fill,...
                'MarkerEdgeColor',layerplot_color_here_edge,...
                'LineWidth',layerplot_linewidth(iik),'MarkerSize',mymarkersize)
            
               accumulatingLegend={accumulatingLegend{:} names4legend_all_sources{iik}};  
              
               
        end
    end
    
    layerplot_marker_walter='d-';
    
    if WalterOn==1
        plot(100.*Liquids_3GPA_Walter1998(:,end), Liquids_3GPA_Walter1998(:, yvalue),layerplot_marker_walter,'Color',coffee,'LineWidth',1,'MarkerSize',12,'MarkerFaceColor',coffee)
        plot(100.*Liquids_4GPA_Walter1998(:,end), Liquids_4GPA_Walter1998(:, yvalue),layerplot_marker_walter,'Color',airsuperiorityblue,'LineWidth',1,'MarkerSize',12,'MarkerFaceColor',airsuperiorityblue)
        plot(100.*Liquids_4point5GPA_Walter1998(:,end), Liquids_4point5GPA_Walter1998(:, yvalue),layerplot_marker_walter,'Color',blue,'LineWidth',1,'MarkerSize',12,'MarkerFaceColor',blue)
        plot(100.*Liquids_5GPA_Walter1998(:,end), Liquids_5GPA_Walter1998(:, yvalue),layerplot_marker_walter,'Color',green,'LineWidth',1,'MarkerSize',12,'MarkerFaceColor',green)
        plot(100.*Liquids_6GPA_Walter1998(:,end), Liquids_6GPA_Walter1998(:, yvalue),layerplot_marker_walter,'Color',deepOrange,'LineWidth',1,'MarkerSize',12,'MarkerFaceColor',deepOrange)
        plot(100.*Liquids_7GPA_Walter1998(:,end), Liquids_7GPA_Walter1998(:, yvalue),layerplot_marker_walter,'Color',red,'LineWidth',1,'MarkerSize',12,'MarkerFaceColor',red)
        
        WalterLegend = {'Walter 30 kbars' 'Walter 40 kbars' 'Walter 45 kbars' 'Walter 50 kbars' 'Walter 60 kbars' 'Walter 70 kbars'};
        accumulatingLegend={accumulatingLegend{:} WalterLegend{:}}; 
       
    end
    
    xlabel(sprintf('F (%%)'));
    [Xtext,Ytext,FigureTitle] = oxideLabel(1,yvalue);
    ylabel([Ytext,' (wt%)'])
    
    
    
    ax = gca;
    ax.XAxis.MinorTick = 'on';
    increment = 1;
    ax.XAxis.MinorTickValues = ax.XLim(1):increment:ax.XLim(2);
    ax.YAxis.MinorTick = 'on';
    increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
    
    ax.YAxis.MinorTickValues = ax.YLim(1):increment:ax.YLim(2);
    
    
    
    
set(gca,'ticklength',2*[0.0200    0.0500])
    set(gca,'fontsize', 14,'LineWidth',.7,'FontName','Times New Roman')
    set(gca,'XColor', 'k')
    set(gca,'YColor', 'k')
    
    
    ax = gca;
    xlimits = xlim;
    ylimits = ylim;
 
 
    
    axis([round(xlimits, 2, 'significant') round(ylimits, 2, 'significant')]);
    
    
    if strcmp(ax.XScale,'linear')==1
        ax.XAxis.MinorTick = 'on';
        increment = findBestIncrement( ax.XLim(2)- ax.XLim(1),ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1));
        
        numIncre = (ax.XAxis.TickValues(2) -  ax.XAxis.TickValues(1))/increment;
        ax.XAxis.MinorTickValues = ax.XAxis.TickValues(1)-numIncre.*increment:increment:ax.XAxis.TickValues(end)+numIncre.*increment;
    else
        
        set(gca, 'Xtick',unique([[0.001 0.01 .1 1 10 100]]))
        
        curtick = get(gca, 'XTick');
        set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
        
        ax.XAxis.MinorTickValues = [.001:.001:.01 .02:.01:.1 .2:.1:1 2:1:10 20:10:100];
        
        
    end
    
    if strcmp(ax.YScale,'linear')==1
        ax.YAxis.MinorTick = 'on';
        increment = findBestIncrement( ax.YLim(2)- ax.YLim(1),ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1));
        
        
        numIncre = (ax.YAxis.TickValues(2) -  ax.YAxis.TickValues(1))/increment;
        ax.YAxis.MinorTickValues = ax.YAxis.TickValues(1)-numIncre.*increment:increment:ax.YAxis.TickValues(end)+numIncre.*increment;
    else
        
        set(gca, 'Ytick',unique([[0.001 0.01 .1 1 10 100]]))
        
        curtick = get(gca, 'YTick');
        set(gca, 'YTickLabel', cellstr(num2str(curtick(:))));
        
        ax.YAxis.MinorTickValues = [.001:.001:.01 .02:.01:.1 .2:.1:1 2:1:10 20:10:100];
        
        
    end
    
    legend(accumulatingLegend,'location','best')
    
end




